<?php
/**
 * Created by PhpStorm.
 * User: Inhere
 * Date: 2015/2/26
 * Time: 20:05
 * Use :
 * File: RequestHelper.php
 */

namespace ulue\core\request;


class RequestHelper
{
    static public function isUrl($str)
    {
        $rule = '/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i';

        return preg_match($rule,$str)===1;
    }


    /**
     * 清理数数据的空白
     * @param $data array|string
     * @return array|string
     */
    static public function clearSpace($data)
    {
        if (is_scalar($data)) {
            return trim($data);
        }

        array_walk_recursive($data, function( &$value)
        {
            $value = trim($value);
        });

        return $data;
    }

}// end class RequestHelper